import java.io.File;
import java.io.IOException;

public class vuire {
    public void save() {
//使用两个文件,分别保存正排和倒排
        System.out.println("保存索引开始");
        //1.先判断索引对应的目录是否存在
        File indexPathFile = new File(INDEX_PATH);
        if(!indexPathFile.exists()){
            indexPathFile.mkdirs();
        }
        File forwardIndexFile = new File(INDEX_PATH+"forward.txt");
        File invertedIndexFile = new File(INDEX_PATH+"forward.txt");
        try {
            objectMapper.writeValue(forwardIndexFile,forwardIndex);
            objectMapper.writeValue(invertedIndexFile,invertedIndex);
        }
        catch (IOException e) {
            e.printStackTrace();
        }
        System.out.println("保存索引成功");
    }
}
